//
//  NowClassListViewController.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/29.
//

#import "NowClassListViewController.h"
#import "ChoiceClassCell.h"
#import "ClassTimeView.h"

@interface NowClassListViewController ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
{
    UIScrollView *_ScrollView;
    UITableView *_Tabview;
    ChoiceClassCell *Cell;
    ClassTimeView *_NowClassChoiceTimeV;
}
@end

@implementation NowClassListViewController

- (void)viewDidLoad {
    [super viewDidLoad];


    self.view.backgroundColor = rgba(245, 245, 255, 1);
    self.navigationController.navigationBar.hidden = YES;
    NavigationHeadView *navgationheadv = [[NavigationHeadView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, SafeAreaTopHight)];
    navgationheadv.backgroundColor = [UIColor whiteColor];
    navgationheadv.titlelabel.text = @"在线课程";
    navgationheadv.titlelabel.textColor  = [UIColor blackColor];
    [navgationheadv.backbtn addTarget:self action:@selector(returnback) forControlEvents:UIControlEventTouchUpInside];
    navgationheadv.rightbtn.hidden = NO;
    [navgationheadv.rightbtn setTitleColor:rgba(22, 120, 255, 1) forState:0];
    [navgationheadv.rightbtn setTitle:@"高级设置" forState:0];
    [navgationheadv.rightbtn addTarget:self action:@selector(advancedSetBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:navgationheadv];
    
    
    UIView *headBackView = [[UIView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHight, APPwidth, 200)];
    headBackView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:headBackView];
    
    UIView *choicetimev = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    choicetimev.backgroundColor = rgba(22, 120, 255, 1);
    choicetimev.layer.cornerRadius = 2;
    [headBackView addSubview:choicetimev];
    UILabel *choicetimeLab = [[UILabel alloc]initWithFrame:CGRectMake(choicetimev.frame.size.width+choicetimev.frame.origin.x+5, 15, 70, 20)];
    choicetimeLab.text = @"选择时间";
    choicetimeLab.textColor = [UIColor blackColor];
    choicetimeLab.textAlignment = 0;
    choicetimeLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [headBackView addSubview:choicetimeLab];

    UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(choicetimeLab.frame.size.width+choicetimeLab.frame.origin.x+5, 15, APPwidth/2, 20)];
    typeLab.text = @"(打开休息设置，当天不接受预约)";
    typeLab.textColor = rgba(102, 102, 102, 1);
    typeLab.textAlignment = 1;
    typeLab.font = [UIFont systemFontOfSize:12];
    [headBackView addSubview:typeLab];
    
    UISwitch *swich = [[UISwitch alloc]initWithFrame:CGRectMake(typeLab.width+typeLab.x+10, 15, 40, 20)];
    [swich setOnTintColor: rgba(22, 120, 255, 1)];
    swich.on = YES;
    swich.transform = CGAffineTransformMakeScale(0.6, 0.);
    [headBackView addSubview:swich];
//    UIView *choiceclasss = [[UIView alloc]initWithFrame:CGRectMake(typeLab.width+typeLab.x+10, 15, 40, 20)];
//    choiceclasss.backgroundColor = rgba(22, 120, 255, 1);
//    choiceclasss.layer.cornerRadius = 2;
//    [headBackView addSubview:choiceclasss];
    
    _ScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, choicetimeLab.height+choicetimeLab.y+10, APPwidth, 100)];
    _ScrollView.contentSize = CGSizeMake(APPwidth*3-200, 100);
    _ScrollView.backgroundColor = [UIColor whiteColor];
    _ScrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    _ScrollView.bounces = true; // 表明当前滑动是否有反弹效果
    _ScrollView.pagingEnabled = NO; // 分页效果
    _ScrollView.showsHorizontalScrollIndicator = NO;
    _ScrollView.scrollEnabled = true; // 使当前能够滑动和不能滑动
    _NowClassChoiceTimeV = [[ClassTimeView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 100)];
    [_ScrollView addSubview:_NowClassChoiceTimeV];
    [headBackView addSubview:_ScrollView];

    UIView *choiceclass = [[UIView alloc]initWithFrame:CGRectMake(15, _ScrollView.height+_ScrollView.y+10, 3, 15)];
    choiceclass.backgroundColor = rgba(22, 120, 255, 1);
    choiceclass.layer.cornerRadius = 2;
    [headBackView addSubview:choiceclass];
    UILabel *choiceclassLab = [[UILabel alloc]initWithFrame:CGRectMake(choiceclass.frame.size.width+choiceclass.frame.origin.x+5, _ScrollView.height+_ScrollView.y+10, 70, 20)];
    choiceclassLab.text = @"选择课程";
    choiceclassLab.textColor = [UIColor blackColor];
    choiceclassLab.textAlignment = 0;
    choiceclassLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [headBackView addSubview:choiceclassLab];

    
    _Tabview  = [[UITableView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHight, APPwidth, APPheight)];
    _Tabview.delegate = self;
    _Tabview.dataSource = self;
    _Tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_Tabview];
    _Tabview.tableHeaderView = headBackView;
    
}
#pragma mark - UITableView DataSource

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 140;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString * str = @"cell";
    
    Cell  = [tableView dequeueReusableCellWithIdentifier:str];
    if (Cell == nil) {
        
        Cell = [[ChoiceClassCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:str];
    }
    
    
    Cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return Cell;
}



-(void)advancedSetBtnClick{
    NSLog(@"gao ji she zhi ");
    
    
    
}
-(void)returnback{
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark -视图即将出现
-(void)viewWillAppear:(BOOL)animated{
        
    ((TabbarController *)self.tabBarController).tabBarView.hidden = YES;
    
}

@end
